package com.easy.module.system.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * @Project: poly-sec-bigdata
 * @Description: 部门类型
 * @Version:
 * @Date: 2021-12-29
 * @Author: <a href="mailto:1073602@qq.com">Yang Huijing</a>
 */
@Getter
@RequiredArgsConstructor
public enum DeptType {

    ROOT(0, "总部"),
    ORG(1, "机构"),
    DEPT(2, "部门");

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 通过值获取名称
     *
     * @param value
     * @return
     */
    public static String getName(Integer value) {
        AtomicReference<String> nameStr = new AtomicReference<>();
        List.of(values()).forEach(p -> {
            if (p.getValue().equals(value)) {
                nameStr.set(p.getName());
            }
        });
        return nameStr.get();
    }
}
